package com.kizuki.thread;

public class TestThreadLocal {

    /**
     * ThreadLocal 线程隔离
     */
    public static void main(String[] args) {
        ThreadLocal<String> local = new ThreadLocal<>();
        local.set("ThreadLocal");

        new Thread(()->{
            System.out.println("子线程尝试获得local值：");
            System.out.println("ThreadLocal = " + local.get());
        }).start();

        System.out.println("main线程尝试获得local值：");
        System.out.println("main ThreadLocal = " + local.get());
    }

}
